import { lazy } from 'react';
import { RouteConfig } from 'react-router-config';
import BasicLayout from 'layouts/BasicLayout';
import LoginSms from 'admin/pages/LoginSms';
import ResetNewPwd from 'admin/pages/ResetNewPwd';

// 懒加载-页面
const HomePage = lazy(() => import(/* webpackChunkName: "home-page" */ 'admin/pages/HomePage'));
// 智能外呼-系统配置
const MainNum = lazy(
  () => import(/* webpackChunkName: "system" */ 'admin/pages/System/MainNum/Index')
);
const ResourcePool = lazy(
  () => import(/* webpackChunkName: "system" */ 'admin/pages/System/ResourcePool/Index')
);
const PhoneTranslate = lazy(
  () => import(/* webpackChunkName: "system" */ 'admin/pages/System/PhoneTranslate')
);
// 智能外呼-客户管理
const NumProp = lazy(
  () => import(/* webpackChunkName: "client" */ 'admin/pages/Client/NumProp/Index')
);
const NumGroup = lazy(
  () => import(/* webpackChunkName: "client" */ 'admin/pages/Client/NumGroup/Index')
);
const BlackList = lazy(
  () => import(/* webpackChunkName: "client" */ 'admin/pages/Client/BlackList/Index')
);
const WhiteList = lazy(
  () => import(/* webpackChunkName: "client" */ 'admin/pages/Client/WhiteList')
);
// 智能外呼-AI管理
const Robots = lazy(() => import(/* webpackChunkName: "ai" */ 'admin/pages/ai/robots'));
const NotifyFlows = lazy(
  () => import(/* webpackChunkName: "ai" */ 'admin/pages/ai/notifyFlows/Index')
);
const Flow = lazy(
  () => import(/* webpackChunkName: "ai" */ 'admin/pages/ai/robots/version/flow/flow')
);
const Actions = lazy(
  () => import(/* webpackChunkName: "ai" */ 'admin/pages/ai/robots/version/flow/actionsNew')
);
const OperateQa = lazy(
  () => import(/* webpackChunkName: "ai" */ 'admin/pages/ai/robots/version/flow/operateQaNew')
);
const FlowDebugRecord = lazy(
  () => import(/* webpackChunkName: "ai" */ 'admin/pages/ai/robots/version/flow/flowDebugRecord')
);
const NotifySoundLibrary = lazy(
  () =>
    import(/* webpackChunkName: "ai" */ 'admin/pages/ai/notifyFlows/components/NotifySoundLibrary')
);
// 智能外呼-任务管理
const CallTask = lazy(() => import(/* webpackChunkName: "task" */ 'admin/pages/Task/TaskList'));
const TaskDetail = lazy(() => import(/* webpackChunkName: "task" */ 'admin/pages/Task/TaskDetail'));
// 无权限
const NoFoundPage = lazy(
  () => import(/* webpackChunkName: "common-page" */ 'admin/pages/Exception/NoFoundPage')
);
const NoPermissionPage = lazy(
  () => import(/* webpackChunkName: "common-page" */ 'admin/pages/Exception/NoPermissionPage')
);
const BlankPage = lazy(
  () => import(/* webpackChunkName: "common-page" */ 'admin/pages/Exception/NoMenuPage')
);
// 行短、靶向、外呼无权限
const NoSmsAuth = lazy(
  () => import(/* webpackChunkName: "NoPermission" */ 'admin/pages/NoPermission/NoSmsAuth')
);
// 行短
const MassSMS = lazy(
  () => import(/* webpackChunkName: "IndustrySms" */ 'admin/pages/IndustrySms/MassSMS')
);
const ReplyRecord = lazy(
  () => import(/* webpackChunkName: "IndustrySms" */ 'admin/pages/IndustrySms/ReplyRecord')
);
const AddressBook = lazy(
  () => import(/* webpackChunkName: "IndustrySms" */ 'admin/pages/IndustrySms/AddressBook')
);
const TemplateList = lazy(
  () => import(/* webpackChunkName: "IndustrySms" */ 'admin/pages/IndustrySms/TemplateList')
);
const SendRecord = lazy(
  () => import(/* webpackChunkName: "IndustrySms" */ 'admin/pages/IndustrySms/SendRecord')
);
const BatchRecord = lazy(
  () => import(/* webpackChunkName: "IndustrySms" */ 'admin/pages/IndustrySms/BatchRecord')
);
// 靶向
const TargetRelease = lazy(
  () => import(/* webpackChunkName: "TargetSms" */ 'admin/pages/TargetSms/TargetRelease')
);
const TargetTemplate = lazy(
  () => import(/* webpackChunkName: "TargetSms" */ 'admin/pages/TargetSms/TargetTemplate')
);
const TargetSend = lazy(
  () => import(/* webpackChunkName: "TargetSms" */ 'admin/pages/TargetSms/TargetSend')
);
// cas
const CasOrganizations = lazy(
  () => import(/* webpackChunkName: "cas" */ 'admin/pages/Cas/Organizations/index')
);
const CasRoles = lazy(() => import(/* webpackChunkName: "cas" */ 'admin/pages/Cas/Roles/index'));
const CasUsers = lazy(() => import(/* webpackChunkName: "cas" */ 'admin/pages/Cas/Users/index'));
const SensitiveWord = lazy(
  () => import(/* webpackChunkName: "cas" */ 'admin/pages/Cas/SensitiveWord/index')
);
const Signatures = lazy(() => import(/* webpackChunkName: "cas" */ 'admin/pages/Cas/Signatures'));
const Templates = lazy(() => import(/* webpackChunkName: "cas" */ 'admin/pages/Cas/Templates'));
const Abilities = lazy(() => import(/* webpackChunkName: "cas" */ 'admin/pages/Cas/Abilities'));
const ApiToken = lazy(() => import(/* webpackChunkName: "cas" */ 'admin/pages/Cas/ApiToken'));
const CasOperationLog = lazy(
  () => import(/* webpackChunkName: "cas" */ 'admin/pages/Cas/OperationLog')
);

const IndustrySmsStatistics = lazy(
  () => import(/* webpackChunkName: "cas" */ 'admin/pages/Cas/Statistics/industrySms')
);

const TargetedSmsStatistics = lazy(
  () => import(/* webpackChunkName: "cas" */ 'admin/pages/Cas/Statistics/targetedSms')
);

const IntelligentCallStatistics = lazy(
  () => import(/* webpackChunkName: "cas" */ 'admin/pages/Cas/Statistics/intelligentCall')
);

const BillingStatistics = lazy(
  () => import(/* webpackChunkName: "cas" */ 'admin/pages/Cas/Statistics/billing')
);

// 页面路由
// 说明：系统中页面对应的页面组件
const routes: RouteConfig[] = [
  {
    path: '/webapp/login',
    component: LoginSms,
  },
  {
    path: '/webapp/resetNewPwd',
    component: ResetNewPwd,
  },
  {
    path: '/webapp',
    component: BasicLayout,
    routes: [
      {
        exact: true,
        path: '/webapp/homePage',
        component: HomePage,
      },
      // 行短
      {
        exact: true,
        path: '/webapp/industrySms/MassSMS',
        component: MassSMS,
      },
      {
        exact: true,
        path: '/webapp/industrySms/ReplyRecord',
        component: ReplyRecord,
      },
      {
        exact: true,
        path: '/webapp/industrySms/AddressBook',
        component: AddressBook,
      },
      {
        exact: true,
        path: '/webapp/industrySms/TemplateList',
        component: TemplateList,
      },
      {
        exact: true,
        path: '/webapp/industrySms/SendRecord',
        component: SendRecord,
      },
      {
        exact: true,
        path: '/webapp/industrySms/BatchRecord',
        component: BatchRecord,
      },
      // 靶向
      {
        exact: true,
        path: '/webapp/targetSms/TargetRelease',
        component: TargetRelease,
      },
      {
        exact: true,
        path: '/webapp/targetSms/TargetTemplate',
        component: TargetTemplate,
      },
      {
        exact: true,
        path: '/webapp/targetSms/TargetSend',
        component: TargetSend,
      },
      // 外呼
      {
        exact: true,
        path: '/webapp/outbound/task/callTask/detail',
        component: TaskDetail,
      },
      {
        exact: true,
        path: '/webapp/outbound/task/callTask',
        component: CallTask as any,
      },
      {
        exact: true,
        path: '/webapp/outbound/ai/robots/version/flow/flowDebugRecord',
        component: FlowDebugRecord,
      },
      {
        exact: true,
        path: '/webapp/outbound/ai/robots/version/flow/operateQa',
        component: OperateQa,
      },
      {
        exact: true,
        path: '/webapp/outbound/ai/robots/version/flow/actions',
        component: Actions,
      },
      {
        exact: true,
        path: '/webapp/outbound/ai/robots/version/flow',
        component: Flow,
      },
      {
        exact: true,
        path: '/webapp/outbound/ai/robots',
        component: Robots,
      },
      {
        exact: true,
        path: '/webapp/outbound/ai/notifyFlows/notifySoundLibrary',
        component: NotifySoundLibrary,
      },
      {
        exact: true,
        path: '/webapp/outbound/ai/notifyFlows',
        component: NotifyFlows,
      },
      {
        exact: true,
        path: '/webapp/outbound/client/numAttr',
        component: NumProp,
      },
      {
        exact: true,
        path: '/webapp/outbound/client/numGroup',
        component: NumGroup,
      },
      {
        exact: true,
        path: '/webapp/outbound/client/blackList',
        component: BlackList,
      },
      {
        exact: true,
        path: '/webapp/outbound/client/whiteList',
        component: WhiteList,
      },
      {
        exact: true,
        path: '/webapp/outbound/system/resourcePool',
        component: ResourcePool,
      },
      {
        exact: true,
        path: '/webapp/outbound/system/mainNum',
        component: MainNum,
      },
      {
        exact: true,
        path: '/webapp/outbound/system/phoneTranslate',
        component: PhoneTranslate,
      },
      // 系统
      {
        exact: true,
        path: '/webapp/casSystem/organizations',
        component: CasOrganizations,
      },
      {
        exact: true,
        path: '/webapp/casSystem/roles',
        component: CasRoles,
      },
      {
        exact: true,
        path: '/webapp/casSystem/users',
        component: CasUsers,
      },
      {
        exact: true,
        path: '/webapp/casSystem/sensitiveWord',
        component: SensitiveWord,
      },
      {
        exact: true,
        path: '/webapp/casSystem/apiToken',
        component: ApiToken,
      },
      {
        exact: true,
        path: '/webapp/casSystem/operationLog',
        component: CasOperationLog,
      },
      {
        exact: true,
        path: '/webapp/casStatistics/industrySms',
        component: IndustrySmsStatistics,
      },
      {
        exact: true,
        path: '/webapp/casStatistics/targetedSms',
        component: TargetedSmsStatistics,
      },
      {
        exact: true,
        path: '/webapp/casStatistics/intelligentCall',
        component: IntelligentCallStatistics,
      },
      {
        exact: true,
        path: '/webapp/casStatistics/billing',
        component: BillingStatistics,
      },
      {
        exact: true,
        path: '/webapp/cas/signatures',
        component: Signatures,
      },
      {
        exact: true,
        path: '/webapp/cas/templates',
        component: Templates,
      },
      {
        exact: true,
        path: '/webapp/cas/abilities',
        component: Abilities,
      },
      // 其它
      {
        exact: true,
        path: '/webapp/blank',
        component: BlankPage,
      },
      {
        exact: true,
        path: '/webapp/401',
        component: NoPermissionPage,
      },
      {
        path: '/webapp/*',
        component: NoFoundPage,
      },
    ],
  },
  {
    path: '/blank',
    component: BasicLayout,
    routes: [
      {
        path: '/',
        component: BlankPage,
      },
    ],
  },
  {
    path: '/401',
    component: BasicLayout,
    routes: [
      {
        exact: true,
        path: '/401/noSmsAuth',
        component: NoSmsAuth,
      },
      {
        path: '/',
        component: NoPermissionPage,
      },
    ],
  },
  {
    path: '/*',
    component: BasicLayout,
    routes: [
      {
        path: '/',
        component: NoFoundPage,
      },
    ],
  },
  {
    path: '/',
    component: BasicLayout,
  },
];

export default routes;
